<?php
use yii\web\View;
use app\assets\HomeAsset;
use yii\helpers\Url;
HomeAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  'Dashboard'
];
$jsMsgs = $this->context->loadJsMsgs([
  'dashboard',
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    Dashboard
    <small><?=\Yii::t('home', 'Data statistics')?></small>
    <!-- <a href="javascript:void(0);" class="btn btn-link" title="点击刷新数据" id="dashboard-refresh">
      <i class="fa fa-refresh"></i>
    </a> -->
  </h1>
</div>
<div class="panel panel-default">    
  <div class="panel-heading">
    <?=\Yii::t('home', 'Overview')?>
    <ul class="list-inline list-unstyled pull-right">
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body">
    <div class="row">
      <h2 class="data-title text-success"><? if (isset($advertiser['name'])) echo $advertiser['name']; echo ''; ?></h2>
      <div class="col-sm-12">
        <ul class="list-inline stat">
          <li>
            <p><?=\Yii::t('home', 'Balance (To Yday)')?></p>
            <span><strong class="text-primary"><?= number_format($account['remind'], 2, '.', ',') ?></strong>￥</span>
          </li>
          <li>
            <p><?=\Yii::t('home', 'Yesterday Cost')?></p>
            <span><strong class="text-warning"><?= number_format($account['last'], 2, '.', ',') ?></strong>￥</span>
          </li>
          <li>
            <p><?=\Yii::t('home', 'Today Budget')?></p>
            <span><strong class="text-danger"><?= number_format($account['balance'], 2, '.', ',') ?></strong>￥</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <i class="fa fa-pie-chart"></i> 
    <?=\Yii::t('home', 'Data Trend')?>
    <ul class="list-inline list-unstyled pull-right">
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-sm-12">
        <div class="chart-filter">
          <div id="total-date-op" class="chart-date-op mb10 pull-right">
            <div data-toggle="buttons" class="btn-group">
              <label class="btn btn-default btn-sm active">
                <input type="radio" checked="" value="day" name="date-options"><?=\Yii::t('home', 'By Day')?></label>
              <label class="btn btn-default btn-sm">
                <input type="radio" value="week" name="date-options"><?=\Yii::t('home', 'By Week')?></label>
              <label class="btn btn-default btn-sm">
                <input type="radio" value="month" name="date-options"><?=\Yii::t('home', 'By Month')?></label>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm-12">
        <div class="chart-holder" id="advertiser-data" style="height: 450px;"></div>
      </div>
    </div>
  </div>
</div>
<?php
  $dataUrl = Url::to(['get-advertiser-data']);
  // $dataUrl = Yii::getAlias('@web').'/response/home/homeDataList.php';
  //$filter = '';    // 需要屏蔽数据时 $dataFilter = ''， 显示数据 $dataFilter = true
  $this->registerJs("VAM.setVar('FILTER_STATUS','$filter');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_LIST_URL','$dataUrl');", View::POS_HEAD);
?>
<script type="text/javascript" >
  require(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    require(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/home/dashboard.js"]);
  });
</script>
